
<template>
  <div class="workLIstSelect h100">
    <listTableNew v-bind="listSetting" ref="workListTable"></listTableNew>
  </div>
</template>

<script>
import {
  getOrderWorkListApi //查询获取试验单和表单关系
} from "@/api/orderManagement/classification";

export default {
  props: {
    formData: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  data() {
    return {
      selectedData: [],
      listSetting: {
        selectionShow: true,
        showCustomBtn: false,
        showFilterBtn: false,
        pageConfig: {
          pageCode: "defectOrder", //页面标识，用来存储过滤器以及自定义列的时候用
          userId: this.$store.getters.userInfo.id
        },
        searchObj: {
          searchMethod: (params, sortStr) => {
            this.getListData(params, sortStr);
          },
          queryData: {
            code: "",
            name: ""
          },
          searchArr: [
            {
              type: "input",
              label: "表单编号",
              model: "code"
            },
            {
              type: "input",
              label: "表单名称",
              model: "name"
            }
          ]
        },
        actionList: [],
        column: [
          {
            label: "表单编号",
            prop: "code"
          },
          {
            label: "表单名称",
            prop: "name"
          }
        ],
        //表格方法
        tableMethods: {
          //点击行的方法
          rowClick: row => {
            this.$refs.workListTable.rowClickSelect(row);
            // this.$refs.workListTable.selectioned(row)

            // this.$refs.workListTable.selectionCalce(row)
          }
        }
      }
    };
  },
  computed: {},
  created() {},
  mounted() {
    this.init();
  },
  methods: {
    init() {
      let forms = this.formData.forms || [];
      if (forms.length > 0) {
        forms.map(i => {
          this.selectedData.push(i.formId);
        });
      }
      this.getListData();
    },
    getListData(params, sortStr) {
      let form = { ...params };
      let { id, major, orderCode, orderId } = this.formData;
      form.overhaulId = orderId;
      form.major = major;
      getOrderWorkListApi(form).then(res => {
        let data = res.data || [];
        this.$set(this.listSetting, "tableData", data.list || []);
        this.$set(this.listSetting, "totalNumber", data.total);
        let selectData = [];
        data.list.map(i => {
          if (this.selectedData.includes(i.id)) {
            this.$refs.workListTable.selectioned(i);
          }
        });
      });
    },
    //获取选中数据
    getSelectData() {
      let data = this.$refs.workListTable.getSelectData();
      return data;
    }
  }
};
</script>
<style lang="less">
</style>